package jpath

import "github.com/bytedance/sonic/ast"

func Int64(node *ast.Node) int64 {
	switch node.TypeSafe() {
	case V_NUMBER, V_TRUE, V_FALSE, V_ANY, V_STRING:
		val, err := node.Int64()
		if err != nil {
			return 0
		}
		return val
	default:
		return 0
	}
}

func Int(node *ast.Node) int {
	return int(Int64(node))
}
